﻿/*****************************************
 * 
 *  copyright (c) by ylshen
 * 
 *  author : ylshen (syl.lucky@gmail.com)
 *  
 **************************************** */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace JYStockAnalyser.Model
{
    /// <summary>
    /// 指标
    /// </summary>
    [Serializable]
    public class GuideLine
    {        
        GuideLineType m_type;
        YearQuarter m_quarter = new YearQuarter();
        decimal m_value;

        /// <summary>
        /// 指标类型
        /// </summary>
        public GuideLineType Type
        {
            get { return m_type; }
            set { m_type = value; }
        }
        /// <summary>
        /// 年季度
        /// </summary>
        public YearQuarter YearQuarter
        {
            get { return m_quarter; }
            set { m_quarter = value; }
        }
       /// <summary>
       /// 值
       /// </summary>
        public decimal Value
        {
            get { return m_value; }
            set { m_value = value; }
        }

        /// <summary>
        /// 指标类型名称
        /// </summary>
        public string TypeName
        {
            get
            {
                if (this.Type == null) return "";

                return this.Type.GetFullName();
            }
        }

        /// <summary>
        /// 指标空值
        /// </summary>
        public const decimal NULL_VALUE = 0m;

        public virtual string GetTimeSimpleString()
        {
            return YearQuarter.GetTimeSimpleString();
        }

        /// <summary>
        /// 生成指标值字符串
        /// </summary>
        /// <returns></returns>
        public string ToValueString()
        {
            return this.Value.Equals(UNDEFINED_VALUE) ? "-" : this.Value.ToString();
        }

        /// <summary>
        /// 未知值
        /// </summary>
        public const decimal UNDEFINED_VALUE = -77777.77m;

        public static GuideLine CreateUnDefinedValueGuideLine(GuideLineType type, YearQuarter yearQuarter)
        {
            GuideLine line = new GuideLine();
            line.Type = type;
            line.Value = UNDEFINED_VALUE;
            line.YearQuarter = yearQuarter;
            return line;
        }
    }
}
